<?php
    
    if (empty($menu)) {
        $menu = array(
            'Lokacije'       => '/locations',
            'Ponude'         => '/offers',
            'Kampanje'       => array(
                'link' => '/campaigns',
                'children' => array(
                    'Fakture' => '/invoices',
                    'Uplate'  => '/payments'
                )
            ),
            'Klijenti'       => '/clients',
            'Izveštaji'      => array(
                'link'     => 'javascript:void(0)',
                'children' => array(
                    'Dugovanja'        => '/reports/debts',
                    'Zauzeće lokacija' => '/reports/location_occupation'
                )
            ),
            'Podešavanja'    => array(
                'link' => '/settings',
                'children' => array(
                    'Tipovi reklama' => '/ad_types',
                    'Kursna lista'   => '/currency_exchange',
                    'Cene montaže'   => '/mount_prices',
                    'Porezi'         => '/taxes',
                    'Korisnici'      => '/users'
                )
            )
        );
    }
    $here = $this->params->params;
?>
<ul>
    <? foreach($menu as $label => $link): ?>
    <?php
        $sub = is_array($link); 
    ?><li<?= $sub ? ' class="sub"' : '' ?>>
        <? if($sub): ?>
            <? $route = Router::parse($link['link']) ?>
            <? if ($here['controller'] == $route['controller'] && $here['action'] == $route['action']): ?>
                <strong><?= $label ?></strong>
            <? else: ?>
                <?= $this->Html->link($label, $link['link']) ?>
            <? endif ?>
            <?= $this->element('menu', array(
                'menu' => $link['children']
            ))?>
        <? else: ?>
            <? $route = Router::parse($link) ?>
            <? if ($here['controller'] == $route['controller'] && $here['action'] == $route['action']): ?>
                <strong><?= $label ?></strong>
            <? else: ?>
                <?= $this->Html->link($label, $link) ?>
            <? endif; ?>
        <? endif ?>
    </li>
    <? endforeach; ?>
</ul>
